package zone.haiwen.demo.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import zone.haiwen.demo.domain.dao.PassengerMapper;
import zone.haiwen.demo.dto.Passenger;
import zone.haiwen.demo.service.PassengerService;

import static zone.haiwen.demo.config.TimetableConstant.DATA_LENGTH;

/**
 * @Description
 * @Author Kevin
 * @Date 2021-07-08 19:25
 */

@SuppressWarnings("ALL")
@Service
public class PassengerServiceImpl extends ServiceImpl<PassengerMapper, Passenger> implements PassengerService {
    @Override
    public void createTable() {
        this.baseMapper.createTable();
    }

    @Override
    public void insert(Long id, String name, String gender, String age, String gmtCreate, String gmtModified) {
        for (int i = 0; i < DATA_LENGTH; i++) {
            this.baseMapper.insert(id + i, name, gender, age, gmtCreate, gmtModified);
        }
    }

    @Override
    public IPage<Passenger> getPassengerByName(String name, Integer current, Integer limit) {
        Page<Passenger> page = new Page<>(current, limit);
        return this.baseMapper.getPassengerByName(page, name);
    }
}
